home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / Snippets / Platforms & Tools / MacApp / MouseInfo 1.0 / About.cp next >
Encoding:
Text File  |  1992-04-29  |  2.9 KB  |  105 lines  |  [TEXT/MPS ]

  1. //     About.cp
  2. //     Copyright © 1992 by Apple Computer, Inc. All rights reserved.
  3. //    Kent Sandvik DTS
  4. //    This file contains the About box code including any adorners/behaviors
  5. //    The resources are placed in the project .r file
  6. //    Version Info (latest first):
  7. //
  8. //    <1>        khs        1.0        First final version
  9.  
  10.  
  11. #ifndef __ABOUT__
  12. #include "About.h"
  13. #endif
  14.  
  15.  
  16. //    Functions
  17.  
  18. #pragma segment ARes
  19. void CreateAboutBox()
  20. {
  21.     TWindow * aboutBoxWindow;
  22.     CStr255 programName,  versionInfo, finalProduct;
  23.  
  24.     //    Yes, I do know this is a waste of resources to 'macroDontDeadStrip' and
  25.     //    register the adorner type every time we open the About box. However, for the
  26.     //    sake of modularity, where I only need to place a CreateAboutBox() statement
  27.     //    inside the TApplication->DoAboutBox(), it made sense - instead of writing all
  28.     //    kinds of init methods that need to be called from IApplication.
  29.  
  30.     if (gDeadStripSuppression)                    // so the linker doesn't dead strip class info 
  31.         macroDontDeadStrip(TMetalBlueFill);
  32.  
  33.     RegisterStdType("TMetalBlueFill", kBlueMetalLook);// register adorner types
  34.  
  35.     //    Get application name    
  36.     gApplication->GetApplicationName(programName);
  37.  
  38.     //    Get version information
  39.     VersRecHndl versInfo = (VersRecHndl)GetResource(kVersInfoType, kVers1InfoID);
  40.     if (versInfo)                                // short one?
  41.         versionInfo = (**versInfo).shortVersion;// get version info from version 1
  42.     else
  43.         versionInfo = " ";                        // nooooothing
  44.  
  45.  
  46.     //    Create Window
  47.     aboutBoxWindow = gViewServer->NewTemplateWindow(phAboutBox, NULL);
  48.     FailNIL(aboutBoxWindow);
  49.  
  50.     //    Hook in any adorners
  51.     aboutBoxWindow->AddAdorner(NewStdAdorner('blmt', "", 'blmt', kFreeOnDeletion), kAdornBefore, kRedraw);
  52.  
  53.     // Stuff in the version info to the other status view, but first get a ptr to it...
  54.     TStaticText * versionField = (TStaticText *)aboutBoxWindow->FindSubView('sta2');
  55.     finalProduct = programName + CStr255(" ") + versionInfo;
  56.     versionField->SetText(finalProduct, TRUE);
  57.  
  58.     //    Open the About box window, and let the user close it whenever...
  59.     aboutBoxWindow->Open();
  60. }
  61.  
  62.  
  63. //    About Box color adorner
  64.  
  65. CRGBColor gMetalBlue(26312,
  66.                      14340,
  67.                      47359);                    // Setup the metal-blue color
  68.  
  69.  
  70. //    Empty constructor - for avoiding ptabs in global data space
  71. #pragma segment ARes
  72. TMetalBlueFill::TMetalBlueFill()
  73. {
  74. }
  75.  
  76.  
  77. //    Draw TGrayFill Adorner method
  78.  
  79. #pragma segment ARes
  80. pascal void TMetalBlueFill::Draw(TView* itsView,
  81.                                  const VRect&    /*area*/)
  82. {
  83.     CRGBColor saveColor;
  84.     PenState savePenState;
  85.     VRect adornArea;
  86.     CRect QDArea;
  87.     CRect tempRect;
  88.  
  89.     GetPenState(savePenState);                    // save off the current pen state 
  90.     GetIfColor(saveColor);                        // and the foreground color
  91.     PenNormal();
  92.  
  93.     itsView->GetAdornExtent(adornArea);            // get area
  94.     itsView->ViewToQDRect(adornArea, QDArea);
  95.     tempRect = QDArea;
  96.  
  97.     SetIfColor(gMetalBlue);                        // colorize it
  98.     PaintRect(tempRect);
  99.  
  100.     SetIfColor(saveColor);                        // restore the foreground color and the pen
  101.     SetPenState(savePenState);
  102. }
  103.  
  104.  
  105.